{{if false}}<script>{{/if}}{{foreach $colModel as $col}}
    {{if $col|@is_array}}
        {{$column["text"]=$col["text"]}}
        {{$column["datafield"]=$col["datafield"]}}
        {{if isset($col["cellsalign"])}}
            {{$column["cellsalign"]=$col["cellsalign"]}}
        {{/if}}
        {{if isset($col["editable"])}}
            {{$column["editable"]=$col["editable"]}}
        {{else}}
            {{$column["editable"]=false}}
        {{/if}}
        {{if isset($col["filtertype"])}}
            {{$column["filtertype"]=$col["filtertype"]}}
        {{/if}}
        {{if isset($col["filterable"])}}
            {{$column["filterable"]=$col["filterable"]}}
        {{else}}
            {{$column["filterable"]=true}}
        {{/if}}
        {{if isset($col["filteritems"])}}
            {{$column["filteritems"]=$col["filteritems"]}}
        {{/if}}
        {{if isset($col["sortable"])}}
            {{$column["sortable"]=$col["sortable"]}}
        {{else}}
            {{$column["sortable"]=true}}
        {{/if}}
        {{if isset($col["columntype"])}}
            {{$column["columntype"]=$col["columntype"]}}
        {{/if}}
        {{if isset($col["threestatecheckbox"])}}
            {{$column["threestatecheckbox"]=$col["threestatecheckbox"]}}
        {{/if}}
        {{if isset($col["cellsformat"])}}
            {{$column["cellsformat"]=$col["cellsformat"]}}
        {{/if}}
        {{if isset($col["hidden"])}}
            {{$column["hidden"]=$col["hidden"]}}
        {{/if}}
        {{if isset($col["width"])}}
            {{$column["width"]=$col["width"]}}
            {{$column["minwidth"]=$col["width"]}}
        {{else}}
            {{$column["minwidth"]=100}}
        {{/if}}
        {{$columns[$col["datafield"]]=$column}}
        {{$column=[]}}
        {{$datafield["name"]=$col["datafield"]}}
        {{if isset($col["type"])}}
            {{$datafield["type"]=$col["type"]}}
        {{else}}
            {{$datafield["type"]="string"}}
        {{/if}}
        {{$listitem["label"]=$col["text"]}}
        {{$listitem['value']=$col["datafield"]}}
        {{if isset($col["hidden"])}}
            {{$listitem["checked"]=!$col["hidden"]}}
        {{else}}
            {{$listitem["checked"]=true}}
        {{/if}}
        {{$listitems[]=$listitem}}
        {{$listitem=[]}}
    {{else}}
        {{$column["text"]=$col}}
        {{$column["datafield"]=$col}}
        {{$column["editable"]=false}}
        {{$datafield["type"]="string"}}
        {{$columns[$col]=$column}}
        {{$column=[]}}
        {{$datafield["name"]=$col}}
        {{$listitem["label"]=$col}}
        {{$listitem['value']=$col}}
        {{$listitem["checked"]=true}}
        {{$listitems[]=$listitem}}
        {{$listitem=[]}}
    {{/if}}
    {{$datafields[]=$datafield}}
    {{$datafield=[]}}
{{/foreach}}
var adatafiels  =   {{$datafields|@json_encode}};
var acolumns    =   {{$columns|@json_encode}};
var alistitems  =   {{$listitems|@json_encode}};
function initSetting(){
    $("#jqxRadioButton_hide").jqxRadioButton({ width: 178, height: 20,groupName :"gridSetting", checked: '0' =='{{$display}}', theme: "classic" });
    $("#jqxRadioButton_show").jqxRadioButton({ width: 178, height: 20,groupName :"gridSetting", checked: '-1'=='{{$display}}',theme: "classic" });
    $("#jqxRadioButton_all").jqxRadioButton ({ width: 178, height: 20,groupName :"gridSetting", checked: '1' =='{{$display}}',theme: "classic" });
    $("#jqxRadioButton_hide,#jqxRadioButton_show,#jqxRadioButton_all").bind('change', function (event) {
        try{
            var checked = event.args.checked;
            if (checked) {
                var _display=0;
                switch(event.target.id){
                    case "jqxRadioButton_hide":
                        _display=0;
                        break;
                    case "jqxRadioButton_show":
                        _display=-1;
                        break;
                    case "jqxRadioButton_all":
                        _display=1;
                        break;
                }
                var url,data;
                url="{{base_url()}}backend/a05b85f8df775a1ecd4a1958174cdc48/change_delete_display/{{$controller}}";
                data={
                    _display:_display
                }
                myAjax(url,data,function(o){
                    if(o.result<0){
                        uiMessage(o.message);
                    }else{
                        myGrid.jqxGrid('updatebounddata');
                    }
                });
            }
        }catch(e){
            uiMessage(e.message);
        }
    });
    $("#jqxListBox_Columns").jqxListBox({ 
        checkboxes: true,
        source: {{json_encode($listitems)}}, 
        width: 234, 
        height: 184, 
        theme: "classic" 
    }).bind('checkChange', function (event) {
        try{
            if (event.args) {
                var hide=1;
                if (event.args.checked) {
                    myGrid.jqxGrid('showcolumn', event.args.value);  
                    hide=0;
                }else {
                    myGrid.jqxGrid('hidecolumn', event.args.value);
                }
                var url,data;
                url="{{base_url()}}backend/a05b85f8df775a1ecd4a1958174cdc48/change_column_display/{{$controller}}";
                data={
                    col     :   event.args.value,
                    hide    :   hide
                }
                myAjax(url,data);
            }
        }catch(e){
            uiMessage(e.message);
        }
    });
}